<template>
  <div>
    <h1>登录界面</h1>
    <van-form @submit="onSubmit">
      <van-field
        v-model="username"
        name="username"
        label="用户名"
        placeholder="用户名"
        :rules="[{ required: true, message: '请填写用户名' }]"
      />
      <van-field
        v-model="password"
        type="password"
        name="password"
        label="密码"
        placeholder="密码"
        :rules="[{ required: true, message: '请填写密码' }]"
      />
      <div style="margin: 16px">
        <van-button
          class="mybutton"
          round
          block
          type="info"
          native-type="submit"
          >提交</van-button
        >
      </div>
    </van-form>
  </div>
</template>

<script>
import Vue from 'vue';
import{Form,Field} from 'vant';
Vue.use(Form)
Vue.use(Field)
export default {
//   name: "ProfileView",
  data() {
    return {
      username: "",
      password: "",
    };
  },
  methods: {
    onSubmit(values) {
      console.log("submit", values);
      localStorage.setItem('username',values.username)
      localStorage.setItem('password',values.password)
      this.$toast("欢迎登录,用户" + values.username);
      this.$router.push('/home')
    },
  },
};
</script>

<style lang="less" scoped>
h1{
    font-size: 0.2rem;
}
.mybutton {
  background-color: red;
  border: 0;
}
</style>